import React from 'react';
import ReactDOM from 'react-dom';
import qqq from 'prop-types'

/* 
  c创造一个上下文  首先 声明上下文中的数据类型
  static childContextTypes = {
      theme:qqq.string,
      title:qqq.string
    }
  getChildContext(){
      return {
        theme:'red',
        title:'珠峰'
      }
    }
*/
class Btn extends React.PureComponent{
  static contextTypes = {
    title:qqq.string
  }
  render(){
    return <button>{this.context.title}</button>
  }
}
class Show extends React.PureComponent{
  static contextTypes = {
    theme:qqq.string
  }
  render(){
    console.log(this)
    return <div>
      <Btn/>
      hahahah{this.context.theme}
    </div>
  }
}

class App extends React.Component {
    static childContextTypes = {
      theme:qqq.string,
      title:qqq.string
    }
    getChildContext(){
      return {
        theme:'red',
        title:'珠峰'
      }
    }
    constructor() {
        super();
        
    }
    render() {
        return <div className=''>
            <Show></Show>
        </div>;
    }
}

ReactDOM.render(<App/>,document.getElementById('root'))